package com.lyc.struct;

public class ForDemo02 {
    public static void main(String[] args) {

    //练习1：计算0到100之间的奇数和偶数的和
        int sumOdd = 0;
        int sumEven = 0;
        for (int i = 0; i <= 100; i++) {
            if (i % 2 == 0) {
                sumEven += i;
            } else {
                sumOdd += i;
            }
        }
        System.out.println("0到100之间的奇数和为：" + sumOdd);
        System.out.println("0到100之间的偶数和为：" + sumEven);
    }
}
